package entities;

/*
    父类包含成员变量：血量，x，y，图片，图片宽，图片高
 */

import index.StartGame;
import tools.Award;

import java.util.Random;

public class Bee extends FlyingObject implements Award {
    private int speed_X, speed_Y;

    public Bee() {
        //初始位置(y值随机，x值随机)
        //未定义位置
        super(0,
                0,
                0,
                StartGame.bee,
                0
        );
        speed_X = StartGame.BEE_SPEED_X;
        speed_Y = StartGame.BEE_SPEED_Y;
    }

    @Override
    public void move() {
        /*
            用  == 号只适用于速度为一的移动
         */
        //特殊斜飞
        //初始默认左上角开始向右移动
        setX(getX() + speed_X);  //x方向移动
        setY(getY() + speed_Y);  //y方向移动
        if (getX() + getAppearance().getWidth() >= StartGame.INTERFACE_WIDTH || getX() <= 0){
            //碰右壁
            speed_X *= -1;
        }
    }

    public int getSpeed_X() {
        return speed_X;
    }

    public void setSpeed_X(int speed_X) {
        this.speed_X = speed_X;
    }

    public int getSpeed_Y() {
        return speed_Y;
    }

    public void setSpeed_Y(int speed_Y) {
        this.speed_Y = speed_Y;
    }

    @Override
    public void giveAward(HeroPlane hero) {
        //给奖励
        int flag = new Random().nextInt(10);
        if (flag < 10 - StartGame.BEE_AWARD_ODDS){
            //大概率
            hero.setHP(hero.getHP() + 1);  //加一条命
        }else {
            //小概率
            hero.setBulletType(1);   //待完善
        }
    }
}
